package controller

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"kf/models/dao"
	"kf/models/entity"
	"kf/utils/R"
	"net/http"
)

// 日志
type LogController struct {
	LogDao *dao.LogDao
	Log    *zap.Logger
}

func (logController *LogController) ListPagedLogs(context *gin.Context) {
	var page entity.LogPageQuery
	err := context.ShouldBindQuery(&page)
	if err != nil {
		// 如果转换失败，返回错误响应
		context.JSON(http.StatusInternalServerError, "Invalid ID")
		return
	}
	form, err := logController.LogDao.ListPagedLogs(page)
	if err != nil {
		context.JSON(http.StatusOK, R.ReturnFailMsg(err.Error()))
		return
	}
	context.JSON(http.StatusOK, R.ReturnSuccess(form))
}
